package com.minelx.scriptbuilder.script;

import com.minelx.scriptbuilder.script.attribute.value.IAttribute;

public class Variable implements IVariable {

	private final IVariable parent;

	private final String selfName;

	public Variable(IVariable parent, String selfName) {
		this.parent = parent;
		this.selfName = selfName;
	}

	@Override
	public IAttribute value() {
		return parent.value().value(selfName);
	}

	@Override
	public void assigned(IAttribute as) {
		parent.value().set(selfName, as);
	}

	@Override
	public String toString() {
		return "Variable{" +
				"parent=" + parent +
				", selfName='" + selfName + '\'' +
				'}';
	}
}
